using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Mgh.Data.Sql;
using Jewelry.BussinessLayer;
using Jewelry.Entities;
using System.Collections.Generic;
using System.Globalization;

public partial class Pages_AManageCart : Mgh.UI.Sql.PageBase
{
    #region properties

    private CartBLL bn;

    #endregion

    #region events

    override protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!IsPostBack)
        {
            txtEnd.Text = txtStart.Text = System.DateTime.Now.ToShortDateString();
        }
    }

    protected void odsCreating(object sender, ObjectDataSourceEventArgs e)
    {
        bn = new CartBLL(getCurrentConnect());
        e.ObjectInstance = bn;
    }

    protected void odsSelecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        e.InputParameters["start"] = DateTime.Parse(txtStart.Text);
        e.InputParameters["end"] = DateTime.Parse(txtEnd.Text);
    }

    protected void odsSelected(object sender, ObjectDataSourceStatusEventArgs e)
    {
        if (e.ReturnValue == null)
        {
            cval.IsValid = false;
            cval.Text = bn.getMessage();
        }
    }

    protected void clickDel(object sender, EventArgs e)
    {
        HtmlInputCheckBox ck = new HtmlInputCheckBox();
        List<object> lis = new List<object>();
        CartBLL bn = new CartBLL(getCurrentConnect());
        foreach (GridViewRow row in gv.Rows)
        {
            ck = row.FindControl("ckMember") as HtmlInputCheckBox;
            if (ck.Checked)
            {
                lis.Add(gv.DataKeys[row.DataItemIndex].Value.ToString());
            }
        }
        if (bn.delCarts(lis))
        {
            gv.DataBind();
        }
        else
        {
            cval.IsValid = false;
            cval.Text = bn.getMessage();
        }
    }

    protected void btFilter_Click(object sender, EventArgs e)
    {
        gv.DataBind();
    }

    #endregion

    #region functions

    #endregion
}
